package com.easyexcel.demo;

/**
 * @author zhaoxh
 * @version : ExcelReader.java, v 0.1 2025/6/16 zhaoxh Exp $
 */
import com.alibaba.excel.EasyExcel;
import com.easyexcel.demo.listener.CourseRowReadListener;

import java.util.*;

public class ExcelReader {

    public static void main(String[] args) {
        String excelFilePath = "C:\\Users\\user\\Desktop\\新建文件夹\\response.xlsx";
        Map<Integer, Map<Integer, String>> resultDataMap = new HashMap<>();

        // 定义读取的 Sheet 索引
        int[] sheetIndices = {0, 1, 2};

        for (int sheetIndex : sheetIndices) {
            CourseRowReadListener listener = new CourseRowReadListener();
            EasyExcel.read(excelFilePath, listener)
                    .sheet(sheetIndex)
                    .doRead();

            TreeMap<Integer, String> sortedResultData = new TreeMap<>(listener.getResultData());            // 这里可以对数据进行处理，例如存储到数据库
            resultDataMap.put(sheetIndex, sortedResultData);

        }

        // 打印结果
        resultDataMap.forEach((sheetIndex, dataMap) -> {
            System.out.println("Sheet " + sheetIndex + " 数据：");
            dataMap.forEach((cell, data)-> System.out.println("Cell " + cell + ": " + data));
        });
    }
}
